<template>
    <div class="demo-collapse">
        <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="问题描述" name="des">
                <div class="detail">
                    <img class="image" src="../../../../assets/N皇后/N皇后问题.jpg">
                    <div class="detail-text">
                        <div class="text">
                            N皇后问题是一个经典问题，在一个N*N的棋盘上放置N个皇后，每行刚好放置一个并使其不能互相攻击
                            （同一行，同一列，同一斜线上的皇后都会自动攻击）计算一共有多少种合法的方法放置N个皇后？
                        </div>
                        <el-table :data="tableData" border style="width: 99%;">
                            <el-table-column prop="name" label="名称" align="center"/>
                            <el-table-column prop="time" label="时间复杂度" align="center"/>
                            <el-table-column prop="spatial" label="空间复杂度" align="center"/>
                        </el-table>
                    </div>
                </div>
            </el-collapse-item>
            <el-collapse-item title="相关研究" name="3">
                <ul>
                    <li v-for="item in thesisData" :key="item.title">
                        <a :href="item.link" target="_blank">
                            <div class="thesis">
                                <img class="thesis-cover" src="../../../../icons//thesis.svg" alt="">
                                <div class="thesis-title">
                                    {{ item.title }}
                                </div>
                                <div class="thesis-author">
                                    <span>作者：</span>{{ item.author }}
                                </div>
                                <div class="thesis-time">
                                    <span>时间：</span>{{ item.time }}
                                </div>
                                <div class="thesis-source">
                                    <span>来源：</span>{{ item.source }}
                                </div>
                            </div>
                        </a>
                    </li>
                </ul>
            </el-collapse-item>
            <el-collapse-item title="应用场景" name="4">
                <div class="detail">
                    <img class="use" src="../../../../assets/N皇后/N皇后2.png" alt="">
                    <div class="text">
                        回溯算法在3D打印任务调度、混合流水车间调度、计算机排课、多约束分配等问题上有着广泛应用。
                        除了上述的实例外，回溯算法还可以用于解决八皇后问题、解数独等经典问题，以及一些更加复杂的组合优化问题。
                    </div>
                </div>
            </el-collapse-item>
        </el-collapse>
    </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const activeNames = ref(['1'])
const handleChange = (val: string[]) => {
    console.log(val)
}

// 相关研究部分
const thesisData = [
    {
        title: "改进回溯算法实现N皇后问题求解",
        author: "原慧芳，于慧敏",
        time: "2016年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=0911a07e394bda4fd751335dc7549f93&site=xueshu_se",
    },
    {
        title: "一种求解n皇后问题的概率回溯复合算法",
        author: "徐少飞，张立臣，李鹏",
        time: "2021年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=10040xx0602g0rx0gt4108a031033709&site=xueshu_se",
    },
    {
        title: "n皇后问题(回溯法)",
        author: "驼驼学编程",
        time: "2022年",
        source: "CSDN",
        link: "https://blog.csdn.net/qq_55168827/article/details/124695030?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522170882874516800215079904%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=170882874516800215079904&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_click~default-2-124695030-null-null.142^v99^control&utm_term=N%E7%9A%87%E5%90%8E%E9%97%AE%E9%A2%98&spm=1018.2226.3001.4187",
    },

]

// 复杂度表格描述
const tableData = [
    {
        name: 'N皇后问题',
        time: 'O(N!)',
        spatial: 'O(N)',
    },
]
</script>

<style scoped lang="scss">
* {
    list-style: none;
}

.image {
    width: 290px;
    border-radius: 10px;
    margin-right: 10px;
}

a {
    text-decoration: none;
    /* 去除默认的下划线 */
    outline: none;
    /* 去除旧版浏览器的点击后的外虚线框 */
    color: #000;
    /* 去除默认的颜色和点击后变化的颜色 */
}

.detail {
    display: flex;
    justify-content: center;
    align-items: end;

    .detail-box {
        display: flex;
        flex-direction: column;
    }

    .text {
        margin-left: 10px;
        margin-bottom: 10px;
        cursor: default;
    }

    .use {
        width: 240px;
        height: 150px;
        border-radius: 10px;
    }
}

// 相关研究部分
.thesis {
    width: 98%;
    position: relative;
    left: 20px;
    margin-bottom: 10px;
    font-weight: normal;
    background: #F5F5F5;
    border-radius: 10px;
    transition: all 0.2s linear;

    .thesis-title {
        position: absolute;
        top: 0;
        left: 5px;
    }

    .thesis-author {
        position: absolute;
        top: 25px;
        left: 120px;
    }

    .thesis-time {
        position: absolute;
        top: 45px;
        left: 120px;
    }

    .thesis-source {
        position: absolute;
        top: 65px;
        left: 120px;
    }

    &:hover {
        cursor: pointer;
        transform: translateX(-15px);
    }
}
</style>